const fs = require("fs");
const path = require("path");
function render(res,url,status=200) {
    res.writeHead(status, {
      "content-type": "text/html;charset=utf-8",
    });
    fs.readFile(path.join(__dirname,url),"utf-8",(err, data) => {
        if (err) {
          console.log(err);
        } else {
          res.end(data);
        }
      }
    );    
}
function route(url, res) {
  if (url === "/home") {
    render(res,'./static/home.html')
  } else if (url === "/login") {
    render(res,'./static/login.html')
  } else {
    render(res,'./static/404.html',404)
  }
}
module.exports = route;